package tds.model28;
/**
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName Expression
 * @Description 抽象表达式类
 * @author tds
 * @Date 2020/2/8 18:01
 * @version 1.0.0
 */
public abstract class Expression {

    public void interpret(PlayContext context){
        if(context.getText().length() == 0){
           return;
        }else{
            String playKey = context.getText().substring(0, 1);
            context.setText(context.getText().substring(2));
            double playValue = Double.valueOf(context.getText().substring(0, context.getText().indexOf(" ")));
            context.setText(context.getText().substring(context.getText().indexOf(" ") + 1));
            execute(playKey, playValue);
        }

    }

    // 不同文法解释器有不同的执行处理
    public abstract void execute(String key, double value);
}
